﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using BLL;
using Model;
using System.Web.SessionState;
namespace WebApplication01.AssetHandel
{
    /// <summary>
    /// LoginHandler 的摘要说明
    /// </summary>
    public class LoginHandler : IHttpHandler,IRequiresSessionState
    {
        LoginBLL assbll = new LoginBLL();
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            
            string User = context.Request["User"].ToString();
            string Password = context.Request["Pwd"].ToString();
            string result = string.Empty;
            EmployInfo user = assbll.Login(User, Password);
            if (user.EmpolyID!=0)
            {
                result = "OK";
                context.Session["users"] = user;//将登录信息存储在session中
                //一般处理程序使用session，必须引用接口IRequiresSessionState
                EmployInfo s = context.Session["users"] as EmployInfo;
            }
            else {
                result = "用户名或密码错误";
            }
            context.Response.Write(result);

        }
       
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}